﻿using System;
using DevExpress.Persistent.Validation;
using DevExpress.Xpo;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Liekhus.TimeTracker.Module.UnitTests
{
    [TestClass]
    public class PhoneLogTest
    {
        private Session m_session;
        
        [TestInitialize]
        public void InitializeTest()
        {
            m_session = new Session();
        }

        [TestMethod]
        public void PhoneLogCreationTest()
        {
            DateTime start = DateTime.Now;
            PhoneLog item = new PhoneLog(m_session);
            Assert.IsTrue(item.CreatedOn >= start, "Item Created On not being set correctly at initilization.");
        }

        [TestMethod]
        public void ValidPhoneLogPersistenceTest()
        {
            DateTime start = DateTime.Now;
            PhoneLog item = new PhoneLog(m_session);
            item.Comment = "Phone Log Comment 1";

            item.Save();
            Assert.IsTrue(item.Comment.Equals("Phone Log Comment 1"), "Item was modified on save.");
            Assert.IsTrue(item.CreatedOn >= start, "Item Created On not being set correctly at initilization.");
            //Assert.IsTrue(item.ModifiedOn >= start, "Item Modified On not being set correctly on save.");
        }
    }
}
